package br.com.dufs.mvc.dao.impl;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import br.com.dufs.mvc.dao.interfaces.AguaEstradaDAO;
import br.com.dufs.mvc.model.AguaEstrada;

import com.fscoreunipe.mvc.dao.impl.generico.DaoGenericoImpl;

@Repository("aguaEstradaDAO")
public class AguaEstradaDAOImpl extends DaoGenericoImpl<AguaEstrada, Integer>
		implements AguaEstradaDAO {

	private Query query;

	@Transactional(readOnly = false)
	@Override
	public AguaEstrada pesquisarPorCPF(String id) {
		// TODO Auto-generated method stub

		AguaEstrada retorno = new AguaEstrada();

		this.query = getSessionFactory().getCurrentSession().createQuery(
				"From AguaEstrada where  entrevistado='" + id + "'");

		if (this.query.uniqueResult() != null) {
			retorno = (AguaEstrada) this.query.uniqueResult();
		}
		return retorno;

	}

}
